#ifndef CAMERAMANAGER_H
#define CAMERAMANAGER_H

#include <OGRE/OgreCamera.h>
#include <OIS/OISMouse.h>
#include <OIS/OISJoyStick.h>

namespace Viewer {
    
class CameraManager : public Ogre::MovableObject::Listener
{
public:
    CameraManager(Ogre::Camera* camera);
    ~CameraManager();
    
    void attach(Ogre::Entity* object);
    
    bool mouseMoved(const OIS::MouseEvent &arg);
    bool mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
    bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
    
    bool axisMoved(const OIS::JoyStickEvent &arg, int axis);
    
    void nextFrame(const Ogre::FrameEvent& event);
    
    void objectMoved(Ogre::MovableObject*);
    
    void setJoystick(OIS::JoyStick* joystick);
    
private:
    void updateCamera();
    
    Ogre::Camera* _camera;
    Ogre::Entity* _object;
    Ogre::Vector3 _objectPosition;
    Ogre::Vector3 _cameraPosition;
    
    OIS::JoyStick* _joystick;
    
    int _mouseX, _mouseY;
    double angleX;
    double angleY;
};

}

#endif // CAMERAMANAGER_H
